<?php

namespace app\service;

use Elasticsearch\ClientBuilder;

class ElasticsearchService extends BaseService
{
    protected function initialize() {
    }

    public function connectElasticsearch(): \Elasticsearch\Client
    {
        $hosts = [
            "106.15.46.172:9201"
        ];
        return ClientBuilder::create()
            ->setHosts($hosts)
            ->build();
    }
    public function addIndex($client,$param) {
        return $client->indices()->create($param);
    }
    public function insertData($client,$data) {
        return $client->index($data);
    }
    public function search($client,$data) {
        return $client->search($data);
    }
}